import FastClick from 'fastclick'
import Vue from 'vue'
import Router from 'vue-router'
//配置路由规则
import routerMap from './routers'
//加载数据请求组件
import VueResource from 'vue-resource'

import App from './App.vue'
Vue.use(Router)
Vue.use(VueResource)

const router = new Router({
});
routerMap(router);

//消除click延迟
if ('addEventListener' in document) {
    document.addEventListener('DOMContentLoaded', function () {
        FastClick.attach(document.body);
    }, false);
}
router.redirect({
	'*': '/'
})

window.routeList=[];

router.beforeEach(function(transition){
  if(routeList.length>1 && transition.to.name==routeList[routeList.length-2]['name']){
    router.app.effect = 'back';
    routeList.splice(routeList.length-1,1);
  }else{
    router.app.effect='fade';
      routeList.push({
        name : transition.to.name,
        path : transition.to.path,
        query : transition.to.query,
        params : transition.to.params,
        timer: +new Date
      });
  }
  transition.next();
})

router.afterEach(function(transition){
    for (var i = 0; i < routeList.length; i++) {
    };
  });

router.start(App, '#app')

